# coding=utf8
import time

from myself_robot.moudle.login import Login
from myself_robot.handle.handle_data import Handle
from myself_robot.report.creat_report import Creat_report
from myself_robot.mytools.tools import *


class Run:
    l = Login()

    def running(self):
        datas = Handle().handle()
        rsts = []
        for i in datas:
            if i.flog == '1':
                rsts.append(['skip'])
                continue
            else:
                rst = list(self.l.login(i.step.get('username'), i.step['password'], i.step['verifycode']))
                # print(rst)
                if len(rst) == 2:
                    # print(i.exp,rst[0])
                    if rst[0] == i.exp:
                        rsts.append(['pass', rst[1]])
                    else:
                        rsts.append(['fail', rst[1]])
                else:
                    # print(i.exp, rst)
                    if rst == i.exp:
                        rsts.append(['pass'])
                    else:
                        rsts.append(['fail'])
        # print(rsts)
        report = Creat_report()
        report.creat_report(rsts)
        time.sleep(1)
        # Login.d.quit()
        Login.d.maximize_window()
        Login.d.get(pro_path() + r'\report\main.html')


if __name__ == '__main__':
    r = Run()
    r.running()
